# coding:utf8
from project.SipMachine.pack.make_driver import driver
from .pages.sip_process_page import SipMainPage
from .utils.locators import LocalMainContain, LocalMainLeft, LocalMainTOp
from selenium.webdriver.common.keys import Keys  # 按键

# ctrl
# Keys.CONTROL
# .send_keys(keys.CONTROL + 't')

from log import logger
VERSION_SIP_APPEAR = ['', '', ]

from project.SipMachine.var import Path

from project.SipMachine.pages.basesip import ParamPublic
from project.SipMachine import pcname_self
paramPublic = ParamPublic(Path.configSipTestDict.get(pcname_self))

"""
#-----  --------在新标签页请求URL---------------------#
driver.execute_script('window.open("","_blank");')  #新建标签页
driver.switch_to.window(driver.window_handles[1])  #切换标签页
"""

class ProcessSip:
    def __init__(self, driver):
        # 允许登陆
        self.allow_login = True
        # 允许 修改配置
        self.allow_config = True
        # 允许 调试功放
        self.allow_meiti = True
        # 允许 更新
        self.allow_update = False
        # 允许 修改ip后,再重新登陆,看IP修改是否正确
        self.allow_check_after_config = True
        
        # 本机的版本
        self.version_curr = ""
        # 媒体选项的状态 是在左是在右
        self.status_mt = ""
        # 原始的IP
        self.ip_original= "192.168.8.143"
        # 将要修改成的ip
        self.ip = ""
        # sip的型号
        self.sip_age = "new"
        # 配置文件的路径
        self.path_data_file = ""
        
        self.mainpage = SipMainPage(driver, paramPublic)
        
        
    def run(self):
        if self.allow_login:
            logger.info("现在开始 `登陆` ")
            # 接着判断是不是在login页
            #
            self.mainpage.open_page_from_ip(self.ip_original)
            self.mainpage.login()
            
        
        self.allow_config = 0
        if self.allow_config:
            logger.info("现在开始 `配置` 设置")
            # 判断现在哪一页
            self.mainpage.process_config()
            # self.mainpage.quit()
            
        self.allow_meiti = 1
        if self.allow_meiti:
            logger.info("现在开始 MT　设置～")
            
            self.mainpage.open_ip_from_file()
            
            # self.mainpage.process_mt()
        
        
            
            

def main():
    obj = ProcessSip(driver=driver)
    obj.run()
    import time
    
    while 1:
        time.sleep(1)
        
    
    
        
        
        
        
    
    
    
